/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package etherblocks.mods;

import com.jme3.app.state.AppState;
import de.lessvoid.nifty.screen.ScreenController;
import etherblocks.engine.*;
import etherblocks.engine.network.*;
import etherblocks.engine.states.*;
import etherblocks.game.World;
import etherblocks.game.entitysystem.*;
import etherblocks.texturepacks.TexturePack;

/**
 *
 * @author Carl
 */
public class Mod{

    public Mod(String title){
        this.title = title;
        properties.setValue("isBlockTerrainEditable", true);
        properties.setValue("isItemBarVisible", true);
        properties.setValue("isCrosshairVisible", true);
        properties.setValue("isCameraChangable", true);
        properties.setValue("isRespawnAllowed", true);
    }
    protected MainApplication mainApplication;
    private final String title;
    protected CustomProperties properties = new CustomProperties();
    
    public void onGameStarted(){
        
    }
    
    protected void setTexturePack(TexturePack texturePack){
        mainApplication.getStateManager().getState(TexturePackAppState.class).setTexturePack(texturePack);
    }
    
    protected void addEntitySystem(EntitySystem entitySystem){
        mainApplication.getStateManager().getState(EntitySystemAppState.class).addEntitySystem(entitySystem);
    }
    
    protected void addNifty(String niftyPath){
        mainApplication.getStateManager().getState(NiftyAppState.class).createNifty(niftyPath);
    }
    
    protected <T extends ScreenController> T getScreenController(Class<T> screenControllerClass){
        return mainApplication.getStateManager().getState(NiftyAppState.class).getScreenController(screenControllerClass);
    }
    
    protected World getWorld(){
        return mainApplication.getStateManager().getState(WorldAppState.class).getWorld();
    }
    
    protected int getPlayerEntityID(){
        return getNetworkClient().getGameClient().getPlayerEntityID();
    }
    
    protected NetworkClient getNetworkClient(){
        return mainApplication.getStateManager().getState(NetworkAppState.class).getNetworkClient();
    }
    
    protected void addAppState(AppState appState){
        mainApplication.getStateManager().attach(appState);
    }
    
    public GameClient createGameClient(){
        return new GameClient();
    }
    
    public GameServer createGameServer(){
        return new GameServer();
    }

    public String getTitle(){
        return title;
    }

    public CustomProperties getProperties(){
        return properties;
    }

    public void setMainApplication(MainApplication mainApplication){
        this.mainApplication = mainApplication;
    }
}
